<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bootstrap Circular Buttons</title>
    <!-- 引入 Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <header class="bg-dark text-white text-center py-5">
        <h1>Welcome to Our Website</h1>
        <p>Creating Beautiful and Responsive Web Pages</p>
    </header>
    <section class="container my-5 text-center">
        <div class="row">
            <div class="col-md-4">
                <button class="btn btn-primary btn-circle btn-xl" onclick="showMessage('Blue')">
                    <i class="bi bi-pencil"></i>
                </button>
                <h2>Blue</h2>
                <p>Light It Up Blue.</p>
            </div>
            <div class="col-md-4">
                <button class="btn btn-success btn-circle btn-xl" onclick="showMessage('Green')">
                    <i class="bi bi-lightbulb"></i>
                </button>
                <h2>Green</h2>
                <p>Light It Up Green.</p>
            </div>
            <div class="col-md-4">
                <button class="btn btn-danger btn-circle btn-xl" onclick="showMessage('Red')">
                    <i class="bi bi-heart"></i>
                </button>
                <h2>Red</h2>
                <p>Light It Up Red</p>
            </div>
        </div>
    </section>
    <footer class="bg-dark text-white text-center py-3">
        <p> 2023  </p>
    </footer>

    <!-- 引入 Bootstrap JavaScript -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- 引入 Bootstrap Icons（可选） -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.20.0/font/bootstrap-icons.js"></script>
    
    <script>
        function showMessage(action) {
            alert("Has sent a message to the Raspberry PI to light the   '" + action + "' light.");
            if ("WebSocket" in window)
            {
               let url="ws://" + location.host;
               var ws = new WebSocket(url);

               ws.onopen = function()
               {
                  ws.send(action);
                  //alert("Has sent a message to the Raspberry PI to light the   '" + action + "' light.");
                  alert("websocket send successfully!")
               };  
               
               ws.onmessage = function(event)
               {
                    const message = event.data;
                    alert(message);
               }
            }
            else{
               alert("WebSocket NOT supported by your Browser!");
            }
            
        }
    </script>
</body>
</html>
